package jco3.sessionManagement_JCoContext_Different;

import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoException;

import jco3.sessionManagement_JCoContext.RfcFunctions;

public class WorkingThread extends Thread{

	private boolean doneSignal;
	private JCoDestination destination;
	
	public WorkingThread(JCoDestination destination,boolean doneSignal) {
		this.destination = destination;
		this.doneSignal = doneSignal;
	}
	
	public boolean hasDone() {
		return doneSignal;
	}
	
	public void run() {
		/**
         * run method of runIncrement() for five times
         */
		
		for(int i=0;i<5;i++) {
			try {
				RfcFunctions.runIncrement(this.destination);
				System.out.println("Run " + (i+1) + " times.");
			} catch (JCoException e) {
				e.printStackTrace();
			}
		}
		this.doneSignal = true;
	}
}
